<!-- 离场管理详情 -->
<script>
import bus from "@/eventBus";
import InterviewDetailLeftNav from "@/components/detailCommons/interviewDetailLeftNav";
import PeopleBasicInfo from "@/components/detailCommons/PeopleBasicInfo";
import PeopleSelfInfo from "@/components/detailCommons/PeopleSelfInfo";
import PeopleOutInfo from "@/components/detailCommons/PeopleOutInfo";
import { getOutAllById } from "@/fetch/modules/peopleout";
import { getArrangeDetilInfo } from "@/fetch/modules/arrange";
import { dec_baseInfo } from "@/decs/dec_peopleBaseInfo";
export default {
  components: {
    InterviewDetailLeftNav,
    PeopleSelfInfo,
    PeopleOutInfo,
    PeopleBasicInfo,
  },
  data() {
    return {
      userInfo: {
        name: "",
        ex: "",
        fileUrl: "",
        cvdbId: "",
      },
      navs: [
        {
          lable: "基本信息",
          id: "1",
          val: "basic",
          isActive: true,
        },
      ],
      nominateInfo: {},
      candidateData: {
        name: "",
        record: "",
        handsOn: "",
        isInJob: "",
        comeTime: "",
        phone: "",
        desc: "",
      },
      basicInfo: {},
      selfInfo: {},
      salaryInfo: {},
      userOutInfo: {},
      statusClassName: "",
      isShowUserStatus: false,
    };
  },
  beforeMount() {
    let id = this.$route.params.id;
    this.needId = id;
    this.state = this.$route.query.stus;
    const needsCvId = this.$route.query.needsCvId;
    // console.log(id, this.state);
    if (this.state !== "0") {
      // 已离场  离场中增加左边tab
      this.navs = [
        {
          lable: "离场信息",
          id: "4",
          val: "leaveInfo",
          isActive: true,
        },
      ];
    } else {
      this.navs = [
        {
          lable: "基本信息",
          id: "1",
          val: "basic",
          isActive: true,
        },
      ];
    }
    if (this.state === "0") {
      // 待离场
    } else if (this.state === "1") {
      // 已离场
      this.statusClassName = "leaveing";
      this.isShowUserStatus = true;
    } else if (this.state === "2") {
      // 离场中
      this.statusClassName = "leaved";
      this.isShowUserStatus = true;
    }
    getOutAllById({ id: id }).then((res) => {
      // console.log(this.$store);
      let tempObj = res.data;
      if (tempObj.state === "0000") {
        let tempData = tempObj.data;
        // console.log(tempData)
        tempData.stus = "";
        this.userOutInfo = {
          ...tempData,
        };

        // 基本信息
        this.basicInfo = dec_baseInfo(tempData);
      }
    });

    if (!needsCvId) return;
    getArrangeDetilInfo({ needsId: needsCvId }).then((res) => {
      const { state, data } = res.data;
      // console.log(res)
      if (state === "0000") {
        this.userInfo = {
          ...data.cvdbInfo,
          name: data.cvdbInfo.surname,
          ex: data.needsDetails.positionName,
          zz: data.cvdbInfo.file_url,
          fileName: data.cvdbInfo.fileName
        };
      }
      console.log(res);
    });
  },
  mounted() {
    bus.$on("select-tab", this.selectPeopleTabItem);
  },
  methods: {
    selectPeopleTabItem(type) {
      console.log(type);
      _j("[mode-type=" + type + "]")
        .siblings(".module-box")
        .removeClass("is-active-tab");
      _j("[mode-type=" + type + "]").addClass("is-active-tab");
    },
  },
  beforeDestroy() {
    bus.$off("select-tab", this.selectPeopleTabItem);
  },
};
</script>

<template>
  <div class="interview-common-detail">
    <li class="resume-detail-left">
      <InterviewDetailLeftNav
        :jobTip="'岗位名称'"
        :statusClassName="statusClassName"
        :isShowUserStatus="isShowUserStatus"
        :isShowGroomBox="false"
        :userInfo="userInfo"
        :navs="navs"
        :nominateInfo="nominateInfo"
      ></InterviewDetailLeftNav>
    </li>
    <li class="resume-detail-right">
      <backButton :backPath="'/peopleout'"></backButton>
      <PeopleOutInfo :candidateInfo="userOutInfo"></PeopleOutInfo>
    </li>
  </div>
</template>

<style lang="scss">
@import "~@/assets/scss/mixins.scss";
@include Interview-detail;
</style>
